package Game;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;

import Game.Keyboard.KeyState;

public class GameOver extends Scene
{
	Button retry, exit;
	
	public static boolean restartLevel;
	
	public GameOver()
	{
		System.out.println("GameOver");
		background = new GameImage(0, 0, Color.WHITE, "/Images/gameover.png");
		retry = new Button(205, 300, "/Images/btn_retry.png", "/Images/btn_retry2.png");
		exit = new Button(312, 430, "/Images/btn_exitmatch.png", "/images/btn_exitmatch2.png");
		retry.isSelected = true;
		restartLevel = true;
	}
	
	@Override
	public void Update() 
	{
		if(Mouse.clicked)
		{
			if(retry.isSelected)
			{
				if(retry.getRectangle().contains(Mouse.actualPosition))
					SceneManager.ChangeScene();
			}
			else if(exit.isSelected)
			{
				if(exit.getRectangle().contains(Mouse.actualPosition))
					SceneManager.ChangeScene();
			}
		}
		if(retry.isMouseColliding())
		{
			retry.isSelected = true;
			exit.isSelected = false;
			restartLevel = true;
		}
		else if(exit.isMouseColliding())
		{
			retry.isSelected = false;
			exit.isSelected = true;
			restartLevel = false;
		}
		if(Keyboard.GetKeyState(KeyEvent.VK_DOWN) == KeyState.PRESSED_ONCE)
		{
			if(retry.isSelected)
			{
				retry.isSelected = false;
				exit.isSelected = true;
				restartLevel = false;
			}
			else
			{
				retry.isSelected = true;
				exit.isSelected = false;
				restartLevel = true;
			}
		}
		else if(Keyboard.GetKeyState(KeyEvent.VK_UP) == KeyState.PRESSED_ONCE)
		{
			if(retry.isSelected)
			{
				retry.isSelected = false;
				exit.isSelected = true;
				restartLevel = false;
			}
			else
			{
				retry.isSelected = true;
				exit.isSelected = false;
				restartLevel = true;
			}
		}
		if(Keyboard.GetKeyState(KeyEvent.VK_ENTER) == KeyState.PRESSED_ONCE)
		{	
			SceneManager.ChangeScene();
		}
	}

	@Override
	public void Draw(Graphics2D g2d) 
	{
		background.Draw(g2d);
		
		retry.Draw(g2d);
		
		exit.Draw(g2d);
	}
}
